﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;

namespace WebApp.Authorization
{
    public class WebAppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
            context.CreatePermission(PermissionNames.Pages_Users_Create, L("UsersCreate"));
            context.CreatePermission(PermissionNames.Pages_Users_Edit, L("UsersEdit"));
            context.CreatePermission(PermissionNames.Pages_Users_Delete, L("UsersDelete"));
            context.CreatePermission(PermissionNames.Pages_Users_AssignRole, L(PermissionNames.Pages_Users_AssignRole));
            

            context.CreatePermission(PermissionNames.Pages_Roles, L(PermissionNames.Pages_Roles));
            context.CreatePermission(PermissionNames.Pages_Roles_Create, L(PermissionNames.Pages_Roles_Create));
            context.CreatePermission(PermissionNames.Pages_Roles_Edit, L(PermissionNames.Pages_Roles_Edit));
            context.CreatePermission(PermissionNames.Pages_Roles_Delete, L(PermissionNames.Pages_Roles_Delete));
            context.CreatePermission(PermissionNames.Pages_Roles_AssignUiMenu, L(PermissionNames.Pages_Roles_AssignUiMenu));
            

            context.CreatePermission(PermissionNames.Pages_Setting, L(PermissionNames.Pages_Setting));

            
            context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, WebAppConsts.LocalizationSourceName);
        }
    }
}
